/***************************************************************************
 *   Copyright (C) 2014 by Philipp Müller                                  *
 *   philipp.mueller@gmx.de                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA          *
 ***************************************************************************/


import QtQuick 2.0

Rectangle {
    id: buttonMenu

    property string text: "MenuButton"
    property string icon: ''

    signal clicked

    width: Math.max( 60 * screenScale, 26 * screenScale + menuButtonLabel.contentWidth )

    height: 60 * screenScale
    radius: 10 * screenScale

    color: "black"
    border.color : "darkgrey"
    border.width : 3 * screenScale

    antialiasing: true

    // color the button with a gradient
    gradient: Gradient {
        GradientStop {
            position: 0.0
            color: {
                if ( mouseArea.pressed )
                    return activePalette.dark
                else
                    return activePalette.light
            }
        }
        GradientStop { position: 1.0; color: activePalette.button }
    }

    MouseArea {
        id: mouseArea
        anchors.fill: parent
        onClicked: {
            buttonMenu.clicked()
        }
    }

    Text {
        id: menuButtonLabel
        anchors.centerIn: parent
        color: activePalette.buttonText
        text: buttonMenu.text
        font.pixelSize: 12 * screenScale
    }

    Image {
        anchors.centerIn: parent
        width: 34 * screenScale
        height: 34 * screenScale
        source: icon
    }
}
